/**
 * 1
 *  
 * @Author : roryrywang
 * @DateTime : 24-9-3 下午6:56
 */

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int res = 0;
    int l = 0, r = n - 1;
    int minValue = 0;
    while (l <= r) {
        if (a[l] <= a[r]) {
            if (minValue <= a[l]) {
                minValue = max(minValue, a[l]);
                res++;
                l++;
            } else if (minValue <= a[r]) {
                minValue = max(minValue, a[r]);
                res++;
                r--;
            } else break;
        } else {
            if (minValue <= a[r]) {
                minValue = max(minValue, a[r]);
                res++;
                r--;
            } else if (minValue <= a[l]) {
                minValue = max(minValue, a[l]);
                res++;
                l++;
            } else break;
        }
    }

    cout << res;

    return 0;
}